//考试资讯管理数据集合。
Ext.define("ES.store.InformationStore",{
    extend:"Ext.data.Store",
    model:"ES.model.InformationModel",
    pageSize:20,
    remoteSort:true,
    autoLoad:false,
    proxy:{
        type:"ajax",
        url:"Information!list.action",
        reader:{
            type:"json",
            root:"dataSource.entityList",
            totalProperty:"dataSource.totalCounts"
        },
        listeners:{
            exception:function(proxy, resp, operation, opt){
                    Ext.MessageBox.show({
                        title:"远程异常",
                        msg:operation.getError(),
                        icon:Ext.MessageBox.ERROR,
                        buttons:Ext.Msg.OK
                    });
                }
        }
    },
    listeners:{
        beforeload:function(store, operation){
            Ext.getBody().mask("正在加载数据，请稍后...");
            Ext.apply(store.proxy.extraParams,{
                ascProperty:"CreateTime",
                asc:false
            });
        },
        load:function(){
            Ext.getBody().unmask();
        },
        update:function(store, record){
            var currPage = store.currentPage;
            Ext.Ajax.request({
                url:"InformationEdit!update.action",
                params:{
                    infoID:record.get("infoID"),
                    infoTitle:record.get("infoTitle"),
                    status:record.get("status"),
                    type:record.get("type"),
                    catalogID:record.get("catalogID"),
                    content:record.get("content"), 
                    createTime:new Date()
                },
                method:"POST",
                success:function(){
                    store.removeAll();
                    store.loadPage(currPage);
                }
            });
        },
        remove:function(store, record){
            var currPage = store.currentPage;
            Ext.Ajax.request({
                   url:"InformationEdit!delete.action",
                   params:{
                        infoID:record.get("infoID")
                   },
                   method:"POST",
                   success:function(){
                    store.removeAll();
                    store.loadPage(currPage);
                 }
              });
        }
    }
})